var ec2_ConfigureAzone = {
    ec2ui_session : null,
    retVal : null,
    loadbalancer : null,
    launch : function() {
        this.retVal.LoadBalancerName = document.getElementById("ec2ui.createlb.Name").value.trim();
	this.retVal.ok = true;
        return true;
    },
    init : function() {
        this.ec2ui_session = window.arguments[0];
        this.retVal = window.arguments[1];
	this.loadbalancer = window.arguments[2];
	
	var configureazone = document.getElementById('Configure_Azone');
	//alert("Here");
        var Idx = 0;
	var AvailabilityZone = this.ec2ui_session.model.getAvailabilityZones();
        var lbZone = this.ec2ui_session.model.getLoadBalancer();
        for (var i in lbZone){
            var LbZone = lbZone[i].Lbzone;
            //alert(LbZone);
        }
        //var lbZone = this.ec2ui_session.model.getLoadBalancer();
        //alert(lbZone);
        //for (var i in lbZone){
        //    var azone = lbZone[i].AvailabilityZones.member;
        //}
        
	for (var i in AvailabilityZone) {
        
	var row = document.createElement('listitem');
	var cell1 = document.createElement('listcell');
	var cell2 = document.createElement('listcell');
        
        var cellID = "cellcheck"+Idx;
	
        var cellAzoneID = "azoneid"+Idx;
	            
	cell1.setAttribute('type', 'checkbox');
        cell1.setAttribute('id',cellID);
	row.appendChild(cell1);
	
        cell2.setAttribute('label', AvailabilityZone[i].name);
        cell2.setAttribute('id',cellAzoneID);
	row.appendChild(cell2);
        
      
       if(AvailabilityZone[i].name == LbZone){
         cell1.setAttribute('checked', 'true'); 
        }
        
        var rowID = "row"+Idx;
	row.setAttribute('id',rowID);
	
        configureazone.appendChild(row);
	
        Idx = Idx +1;
	}
  },
  enable_disableAzone : function(){
      var listBox = document.getElementById('Configure_Azone');
      var selectedItem = listBox.currentIndex;
      if (selectedItem == -1) return null;
      var rowID = "row"+selectedItem;
      var row = document.getElementById(rowID);
      var cellID = "cellcheck"+selectedItem;
      var cell = document.getElementById(cellID);
      var attribute = cell.getAttribute('type');
      if(cell.hasAttribute('checked','true'))
      {
      cell.setAttribute('checked','false');
      cell.removeAttribute('checked');
      }
      else
      {
      cell.setAttribute('checked','true');
      }
      },
 
   
}